home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 November / PCWorld_2007-11_cd.bin / domácnost a kancelar / opencontacts / setup.exe / {app} / DataSet / Templates / defaultContacts.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2007-08-19  |  4.6 KB  |  148 lines

  1. ∩╗┐<?xml version="1.0" encoding="UTF-8"?>
  2. <!--For rendering a list of contacts to HTML
  3. This template does not require translation. However, you may want to change styles.
  4. -->
  5. <xsl:stylesheet version="1.0"
  6. xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  7. <xsl:output method="html" omit-xml-declaration="yes" encoding="UTF-8" />
  8.  
  9.   <xsl:template match="/">
  10.     <html>
  11.  
  12.       <body style="font-size: 10pt">
  13.         <xsl:for-each select="OpenContacts/Contacts/Contact">
  14.  
  15.           <table border="0" width="100%" id="table2">
  16.             <tr>
  17.               <td width="80%">
  18.                 <font face="Times New Roman" size="3">
  19.                   <b>
  20.                     <xsl:value-of select="@Name"/>
  21.                   </b>
  22.                 </font>
  23.               </td>
  24.               <td>
  25.                 <xsl:value-of select="@Title"/>
  26.               </td>
  27.             </tr>
  28.           </table>
  29.           <div style="margin-left: 15px;">
  30.  
  31.                 <xsl:apply-templates select="Notes"/>
  32.  
  33.  
  34.           </div>
  35.           <xsl:for-each select="Sections/Section">
  36.             <div style="margin-left: 15px;">
  37.  
  38.  
  39.               <b>
  40.                 <font face="Times New Roman" size="2">
  41.                   <xsl:value-of select="@Name"/>
  42.                 </font>
  43.               </b>
  44.             </div>
  45.  
  46.  
  47.  
  48.             <table border="0" width="100%" id="table1" cellspacing="0" cellpadding="0">
  49.               <xsl:for-each select="Fields/Field">
  50.                 <tr>
  51.                   <td width="15"></td>
  52.                   <td width="80" bgcolor="#C3D9FF">
  53.                     <font face="Times New Roman" size="2">
  54.                       <xsl:value-of select="@Name"/>:
  55.                     </font>
  56.                   </td>
  57.                   <td bgcolor="#E0ECFF">
  58.                     <font size="3">
  59.  
  60.                       <xsl:choose>
  61.  
  62.                         <xsl:when test="@Action='email'">
  63.  
  64.                           <a href="mailto:{@Value}">
  65.                             <xsl:value-of select="@Value"/>
  66.                           </a>
  67.                         </xsl:when>
  68.  
  69.                         <xsl:when test="@Action='web'">
  70.                           
  71.  
  72.                           <!--Case insensitive match is not big concern.-->
  73.                           <xsl:if test="starts-with(@Value, 'http://')">
  74.                             <a href="{@Value}">
  75.                               <xsl:value-of select="@Value"/>
  76.                             </a>
  77.                           </xsl:if>
  78.                           <xsl:if test="not(starts-with(@Value, 'http://'))">
  79.                             <a href="http://{@Value}">
  80.                               <xsl:value-of select="@Value"/>
  81.                             </a>
  82.                           </xsl:if>
  83.                         </xsl:when>
  84.  
  85.                         <xsl:when test="@Action='skype'">
  86.  
  87.                           <a href="skype:{@Value}">
  88.                             <xsl:value-of select="@Value"/>
  89.                           </a>
  90.                         </xsl:when>
  91.  
  92.                        <xsl:otherwise>
  93.                           <xsl:value-of select="@Value"/>
  94.  
  95.                         </xsl:otherwise>
  96.                       </xsl:choose>
  97.  
  98.                     </font>
  99.                   </td>
  100.                 </tr>
  101.               </xsl:for-each>
  102.  
  103.             </table>
  104.  
  105.             <div style="margin-left: 15px;">
  106.  
  107.               <font size="2" color="#800000">
  108.                 <xsl:apply-templates select="Notes"/>
  109.               </font>
  110.  
  111.             </div>
  112.           </xsl:for-each>
  113.  
  114.           <p>  </p>
  115.         </xsl:for-each>
  116.       </body>
  117.     </html>
  118.   </xsl:template>
  119.  
  120.   <xsl:template match="Notes">
  121.       <xsl:call-template name="substitute">
  122.          <xsl:with-param name="string" select="." />
  123.       </xsl:call-template>
  124. </xsl:template>
  125.  
  126.  <xsl:template name="substitute">
  127.    <xsl:param name="string" />
  128.    <xsl:param name="from" select="' '" />
  129.    <xsl:param name="to">
  130.       <p/>
  131.    </xsl:param>
  132.    <xsl:choose>
  133.       <xsl:when test="contains($string, $from)">
  134.          <xsl:value-of select="substring-before($string, $from)" />
  135.          <xsl:copy-of select="$to" />
  136.          <xsl:call-template name="substitute">
  137.             <xsl:with-param name="string"
  138.                             select="substring-after($string, $from)" />
  139.             <xsl:with-param name="from" select="$from" />
  140.             <xsl:with-param name="to" select="$to" />
  141.          </xsl:call-template>
  142.       </xsl:when>
  143.       <xsl:otherwise>
  144.          <xsl:value-of select="$string" />
  145.       </xsl:otherwise>
  146.    </xsl:choose>
  147. </xsl:template>                
  148. </xsl:stylesheet>